﻿
IF EXISTS (SELECT 1 FROM sys.views v inner join sys.schemas s on v.schema_id=s.schema_id where v.name=N'V_TenantApplicationModules' and s.name=N'cDba')
	DROP VIEW [cDba].[V_TenantApplicationModules]
GO

CREATE VIEW [cDba].[V_TenantApplicationModules]
AS
SELECT   cDba.tenant_TenantUser.TenantId, cDba.tenant_TenantUser.TenantName, cDba.tenant_TenantUser.TenantDisplayName, 
                cDba.tenant_TenantUser.TenantType, cDba.tenant_TenantUser.Version, cDba.tenant_TenantUser.CloudType, 
                cDba.tenant_TenantUser.DatabaseType, cDba.tenant_TenantUser.Server, cDba.tenant_TenantUser.[Database], 
                cDba.tenant_TenantUser.DatabasePasswordHash, cDba.tenant_TenantUser.StorageType, 
                cDba.tenant_TenantUser.StorageEndpoint, cDba.tenant_TenantUser.StorageAccessName, 
                cDba.tenant_TenantUser.StorageAccessKeyPasswordHash, cDba.tenant_TenantUser.QueueType, 
                cDba.tenant_TenantUser.QueueEndpoint, cDba.tenant_TenantUser.QueueAccessName, 
                cDba.tenant_TenantUser.QueueAccessKeyPasswordHash, cDba.tenant_TenantUser.NoSqlType, 
                cDba.tenant_TenantUser.NoSqlEndpoint, cDba.tenant_TenantUser.NoSqlAccessName, 
                cDba.tenant_TenantUser.NoSqlAccessKeyPasswordHash, cDba.tenant_TenantUser.DistributedMessageType, 
                cDba.tenant_TenantUser.ServiceBusEndpoint, cDba.tenant_TenantUser.ServiceBusAccessName, 
                cDba.tenant_TenantUser.ServiceBusAccessKeyPasswordHash, cDba.tenant_TenantUser.ContactName, 
                cDba.tenant_TenantUser.ContactEmail, cDba.tenant_TenantUser.ContactPhone, cDba.tenant_TenantUser.EnableEmail, 
                cDba.tenant_TenantUser.EnableSms, cDba.tenant_TenantUser.EnableCallCenter, 
                cDba.tenant_TenantUser.EnableWeixin, cDba.tenant_TenantUser.EnablePayment, 
                cDba.tenant_TenantUser.EnableLogistics, cDba.tenant_TenantUser.EnableId5, cDba.tenant_TenantUser.NickName, 
                cDba.tenant_TenantUser.NickNameLastModifyDate, cDba.tenant_TenantUser.OwnDomainName, 
                cDba.tenant_TenantUser.OwnDomainLevel, cDba.tenant_TenantUser.PasswordExpiredTime, 
                cDba.tenant_TenantUser.CanEdit, cDba.tenant_TenantUser.ReferenceId, 
                cDba.tenant_TenantUserApplication.ApplicationId, cDba.tenant_TenantUserApplication.ApplicationName, 
                cDba.tenant_TenantUserApplication.DomainName, cDba.tenant_TenantUserApplication.AppStatus, 
                cDba.tenant_TenantUserApplication.WebSiteName, cDba.tenant_TenantUserAppModule.ModuleId, 
                cDba.tenant_TenantUserAppModule.ModuleName, cDba.tenant_TenantUserAppModule.Description, 
                cDba.tenant_TenantUserAppModule.AssemblyName
FROM      cDba.tenant_TenantUser INNER JOIN
                cDba.tenant_TenantUserApplication ON 
                cDba.tenant_TenantUser.TenantId = cDba.tenant_TenantUserApplication.TenantId INNER JOIN
                cDba.tenant_TenantUserAppModule ON 
                cDba.tenant_TenantUserApplication.Id = cDba.tenant_TenantUserAppModule.ApplicationId
GO
